import request from '/shop/request';

export default {
	// 订单详情
	detail: (id) =>
		request({
			url: '/api/user/order/view/' + id,
			method: 'GET',
		}),
	orderDetail: (id) =>
		request({
			url: '/api/user/order/detail/' + id,
			method: 'GET',
		}),
	// 发票详情
	invoice: (id) =>
		request({
			url: '/api/order/invoice/' + id,
			method: 'GET',
		}),
	// 获取支付结果
	payResult: (id) =>
		request({
			url: '/api/order/order/' + id,
			method: 'GET',
			custom: {
				showLoading: false,
			},
		}),
	itemDetail: (id, itemId) =>
		request({
			url: '/api/order/order/itemDetail/' + id + '/' + itemId,
			method: 'GET',
			custom: {
				showLoading: false,
			},
		}),
	// 订单列表
	list: (data) =>
		request({
			url: '/api/user/order/list',
			method: 'POST',
			data,
			custom: {
				showLoading: false,
			},
		}),
	// 计算订单信息
	calc: (data) =>
		request({
			url: '/api/user/order/calc',
			method: 'POST',
			data,
		}),
	// 创建订单
	create: (data) =>
		request({
			url: '/api/user/order/submit',
			method: 'POST',
			data,
		}),
	//订单可用优惠券
	coupons: (data) =>
		request({
			url: '/api/user/order/activity/coupons',
			method: 'POST',
			data,
		}),
	// 确认收货
	confirm: (id) =>
		request({
			url: '/api/user/order/confirm/' + id,
			method: 'PUT',
		}),
	// 评价订单
	comment: (data) =>
		request({
			url: '/api/user/order/goods/comment',
			method: 'POST',
			data,
		}),
	// 申请退款
	applyRefund: (id) =>
		request({
			url: '/api/order/order/applyRefund/' + id,
			method: 'PUT',
		}),
	// 取消订单
	cancel: (id) =>
		request({
			url: '/api/user/order/cancel/' + id,
			method: 'PUT',
		}),
	// 删除订单
	delete: (id) =>
		request({
			url: '/api/order/order/' + id,
			method: 'DELETE',
		}),

	checkOrderLegal: (data) =>
		// 验证限购购买数量....
		request({
			url: '/api/user/order/check/legal',
			data,
			method: 'POST',
		}),

	// 售后
	aftersale: {
		// 申请售后
		apply: (data) =>
			request({
				url: '/api/order/aftersale/create',
				method: 'POST',
				data,
			}),
		list: (data) =>
			request({
				url: '/api/order/aftersale/search',
				method: 'POST',
				data,
				custom: {
					showLoading: false,
				},
			}),
		//取消售后
		cancel: (id) =>
			request({
				url: '/api/order/aftersale/cancel/' + id,
				method: 'PUT',
			}),
		//删除售后单
		delete: (id) =>
			request({
				url: '/api/order/aftersale/delete/' + id,
				method: 'DELETE',
			}),
		// 售后详情
		detail: (id) =>
			request({
				url: '/api/order/aftersale/view/' + id,
				method: 'GET',
			}),
		log: (id) =>
			request({
				url: '/api/order/aftersale/log/content/' + id,
				method: 'GET',
			}),
	},
	//订单包裹
	express: (id, orderId) =>
		request({
			url: '/api/order/express/' + id + `${orderId ? '/' + orderId : ''}`,
			method: 'GET',
		}),
};
